﻿<?xml version="1.0" encoding="utf-8"?>
<!--
        作者：          liuleyi
        更新时间：      20170227
        用途：          生成存储过程默认模板
-->
<xsl:stylesheet version="2.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:fn="http://www.w3.org/2005/xpath-functions">
	<xsl:output method="text" indent="no" encoding="utf-8" byte-order-mark="no"/>  
	<xsl:template match="/">

	<xsl:variable name="StringTypeDefine" select="document('../model/0101_StringTypeDefine.xml')"/>
	<xsl:variable name="EnumTypeDefine" select="document('../model/0102_EnumTypeDefine.xml')"/>
	<xsl:variable name="BooleanTypeDefine" select="document('../model/0103_BooleanTypeDefine.xml')"/>
	<xsl:variable name="DateTypeDefine" select="document('../model/0104_DateTypeDefine.xml')"/>
	<xsl:variable name="NumberTypeDefine" select="document('../model/0105_NumberTypeDefine.xml')"/>
	<xsl:variable name="IntegerTypeDefine" select="document('../model/0106_IntegerTypeDefine.xml')"/>
	<xsl:variable name="FunNoConfig" select="document('../model/0601_FunNoConfig.xml')"/>
<xsl:for-each select="Templates/ListTemplate">

<xsl:variable name="fileName" select="concat('./generate/python/template/',lower-case(@code),'.html')"/>
	<xsl:result-document encoding="utf-8"  method="text" href="{$fileName}">
{% extends "base.html" %}
{% block js %}
&lt;script&gt;
$(document).ready(function(){
<xsl:for-each select="Search">
$(&quot;#search&quot;).click(function(){

<xsl:variable name="FunNo" select="@code"/>
window.location.href=&quot;/polls/<xsl:value-of select="$FunNo"/>/&quot;<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]"><xsl:for-each select="Request"><xsl:for-each select="Column">+$(&quot;#<xsl:value-of select="@name"/>&quot;).val()+&quot;/&quot;</xsl:for-each></xsl:for-each></xsl:for-each>;
});
</xsl:for-each>
<xsl:for-each select="Add">
<xsl:variable name="FunNo" select="@code"/>
$(&quot;#add&quot;).click(function(){
window.location.href=&quot;/polls/<xsl:value-of select="$FunNo"/>/&quot;;
});
</xsl:for-each>

<xsl:for-each select="EditSearch">
<xsl:variable name="FunNo" select="@code"/>
$('#dataTables tbody').on('click', 'button#edit', function () {
var data = $('#dataTables').DataTable().row($(this).parents('tr')).data();
 window.location.href=&quot;/polls/<xsl:value-of select="$FunNo"/>/&quot;+data[1]+&quot;/&quot;;
});
</xsl:for-each>
<xsl:for-each select="Delete">
<xsl:variable name="FunNo" select="@code"/>
$('#dataTables tbody').on('click', 'button#delete', function () {
var data = $('#dataTables').DataTable().row($(this).parents('tr')).data();
 window.location.href=&quot;/polls/<xsl:value-of select="$FunNo"/>/&quot;+data[1]+&quot;/&quot;<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]"><xsl:for-each select="Request"><xsl:for-each select="Field">+$(&quot;#<xsl:value-of select="@name"/>&quot;).val()+&quot;/&quot;</xsl:for-each></xsl:for-each></xsl:for-each>;
});
</xsl:for-each>
});
&lt;/script&gt;
{% endblock %}
{% block title %}<xsl:value-of select="@label"/>{% endblock %}
{% block content %}
&lt;h1&gt;<xsl:value-of select="@label"/>&lt;/h1&gt;
&lt;hr /&gt;
<xsl:for-each select="Search">
<xsl:variable name="FunNo" select="@code"/>
<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]">
&lt;div class=&quot;container&quot;&gt;
<xsl:for-each select="Request"><xsl:for-each select="Column">
<xsl:variable name="typeTable" select="@name"/>
<xsl:if test="(position() mod 2)=1">&lt;div class=&quot;row&quot; &gt;</xsl:if>

&lt;div class=&quot;text-right col-xs-6 col-sm-3 control-label&quot; &gt;&lt;label for=&quot;<xsl:value-of select="@name" />&quot;&gt;<xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&lt;/label&gt;&lt;/div&gt;
&lt;div class="col-xs-6 col-sm-3" >
&lt;input type=&quot;text&quot; id=&quot;<xsl:value-of select="@name" />&quot; class=&quot;form-control&quot; placeholder=&quot;请输入 <xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&quot;  value=&quot;{{<xsl:value-of select="@name" />}}&quot; /&gt;
&lt;/div&gt;
<xsl:if test="(position() mod 2)=0">    &lt;/div&gt;</xsl:if>
<xsl:if test="position()=last()">    &lt;/div&gt;</xsl:if>
</xsl:for-each></xsl:for-each></xsl:for-each></xsl:for-each>
   &lt;div class=&quot;row&quot; &gt;
        &lt;div class=&quot;col-xs-6 col-sm-3 col-xs-offset-6 col-sm-offset-9=&quot; &gt;
<xsl:for-each select="Add">
&lt;td width=&quot;150&quot; &gt;&lt;input type=&quot;button&quot; id=&quot;add&quot;  class=&quot;btn btn-default&quot; value=&quot;新增&quot;&gt;&lt;/td&gt;
</xsl:for-each>
&lt;td width=&quot;150&quot; &gt;&lt;input type=&quot;button&quot; id=&quot;search&quot;  class=&quot;btn btn-default&quot; value=&quot;查询&quot;&gt;&lt;/td&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr /&gt;
<xsl:for-each select="Search">
<xsl:variable name="FunNo" select="@code"/>
<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]">
<xsl:for-each select="Response">
&lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-md-12&quot;&gt;
          <!-- Advanced Tables -->
          &lt;div class=&quot;card&quot;&gt;
              &lt;div class=&quot;card-action&quot;&gt;
              &lt;div&gt;
              &lt;div class=&quot;card-content&quot;&gt;
                  &lt;div class=&quot;table-responsive&quot;&gt;
                      &lt;table class=&quot;table table-striped table-bordered table-hover table-condensed&quot; id=&quot;dataTables&quot; border=&quot;1&quot;&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
&lt;th&gt;序号&lt;/th&gt;
<xsl:for-each select="Column">
<xsl:variable name="typeTable" select="@name"/>
&lt;th&gt;
<xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&lt;/th&gt;
</xsl:for-each>
&lt;th&gt;
操作&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
{% if resp.listdata %}
                          &lt;tbody&gt;
    {% for list in resp.listdata %}
      &lt;tr class=&quot;toggler&quot;&gt;
&lt;td&gt;{{ forloop.counter }}&lt;/td&gt;
<xsl:for-each select="Column">
&lt;td&gt;{{ list.<xsl:value-of select="@name"/> }}&lt;/td&gt;
</xsl:for-each>
&lt;td&gt;&lt;div class=&quot;btn-group&quot;&gt;
    &lt;button id=&quot;edit&quot; type=&quot;button&quot; class=&quot;btn btn-default&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-pencil&quot;&gt;&lt;/span&gt;&lt;/button&gt;
    &lt;button id=&quot;delete&quot; type=&quot;button&quot; class=&quot;btn btn-default&quot;&gt;&lt;span class=&quot;glyphicon glyphicon-remove&quot;&gt;&lt;/span&gt;&lt;/button&gt;
&lt;/div&gt;
&lt;/td&gt;
      &lt;/tr&gt;
    {% endfor %}
                          &lt;/tbody&gt;
{% endif %}
                      &lt;/table&gt;
                  &lt;div&gt;
                  
              &lt;div&gt;
          &lt;div&gt;
          <!--End Advanced Tables -->
      &lt;div&gt;
&lt;div&gt;
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
{% endblock %}
	</xsl:result-document>
</xsl:for-each>


<xsl:for-each select="Templates/EditTemplate">
<xsl:variable name="fileName" select="concat('./generate/python/template/',lower-case(@code),'.html')"/>
	<xsl:result-document encoding="utf-8"  method="text" href="{$fileName}">
{% extends "base.html" %}
{% block js %}
&lt;script&gt;
$(document).ready(function(){
<xsl:for-each select="Save">
$(&quot;#save&quot;).click(function(){

<xsl:variable name="FunNo" select="@code"/>
window.location.href=&quot;/polls/<xsl:value-of select="$FunNo"/>/&quot;<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]"><xsl:for-each select="Request"><xsl:for-each select="Column">+$(&quot;#<xsl:value-of select="@name"/>&quot;).val()+&quot;/&quot;</xsl:for-each></xsl:for-each></xsl:for-each>;
});
</xsl:for-each>
});
&lt;/script&gt;
{% endblock %}
{% block title %}<xsl:value-of select="@label"/>{% endblock %}
{% block content %}
&lt;h1&gt;<xsl:value-of select="@label"/>&lt;/h1&gt;
&lt;hr /&gt;
<xsl:for-each select="Save">
<xsl:variable name="FunNo" select="@code"/>
<xsl:for-each select="$FunNoConfig//FunNo[@code=$FunNo]">
&lt;div class=&quot;container&quot;&gt;
<xsl:for-each select="Request"><xsl:for-each select="Column">
<xsl:variable name="typeTable" select="@name"/>
<xsl:if test="(position() mod 2)=1">&lt;div class=&quot;row&quot; &gt;</xsl:if>

&lt;div class=&quot;text-right col-xs-6 col-sm-3 control-label&quot; &gt;&lt;label for=&quot;<xsl:value-of select="@name" />&quot;&gt;<xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&lt;/label&gt;&lt;/div&gt;
&lt;div class="col-xs-6 col-sm-3" >
&lt;input type=&quot;text&quot; id=&quot;<xsl:value-of select="@name" />&quot; class=&quot;form-control&quot; placeholder=&quot;请输入 <xsl:for-each select="$StringTypeDefine//String[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$EnumTypeDefine//Enum[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$BooleanTypeDefine//Boolean[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$DateTypeDefine//Date[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$NumberTypeDefine//Number[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each><xsl:for-each select="$IntegerTypeDefine//Integer[@typename=$typeTable]"><xsl:value-of select="@label"/>
</xsl:for-each>&quot;  value=&quot;{{<xsl:value-of select="@name" />}}&quot; /&gt;
&lt;/div&gt;
<xsl:if test="(position() mod 2)=0">    &lt;/div&gt;</xsl:if>
<xsl:if test="position()=last()">    &lt;/div&gt;</xsl:if>
</xsl:for-each></xsl:for-each></xsl:for-each></xsl:for-each>
   &lt;div class=&quot;row&quot; &gt;
        &lt;div class=&quot;col-xs-6 col-sm-3 col-xs-offset-6 col-sm-offset-9=&quot; &gt;
&lt;td width=&quot;150&quot; &gt;&lt;input type=&quot;button&quot; id=&quot;save&quot; class=&quot;btn btn-default&quot; value=&quot;保存&quot;&gt;&lt;/td&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr /&gt;
{% endblock %}
	</xsl:result-document>
</xsl:for-each>
</xsl:template>  
</xsl:stylesheet>